require 'parseconfig'
require_relative 'port_status.rb'
require_relative 'send_mail.rb'
require_relative 'insert_sql'

c = ParseConfig.new('test.conf')

#website1 port1
web1 = "#{c.params['website1']['website']}" 
port1 = "#{c.params['website1']['port']}"
status1 =port_status(web1, port1).to_s
if status1 == "false" 
	send_mail("#{port1}", "#{web1}", "#{status1}")
end

sleep 2

#website2 port2
web2 = "#{c.params['website2']['website']}" 
port2 = "#{c.params['website2']['port']}"
status2 = port_status(web2, port2).to_s
if status2 == "false"
	send_mail("#{port2}", "#{web2}", "#{status2}")
end

sleep 2

#website3 port3
web3 = "#{c.params['website3']['website']}" 
port3 = "#{c.params['website3']['port']}"
status3 = port_status(web3, port3).to_s
if status3 == "false"
	send_mail("#{port3}", "#{web3}", "#{status3}")
end

sleep 2

#insert_sql(port, website, status )
insert_sql("#{port1}", "#{web1}", "#{status1}")
insert_sql("#{port2}", "#{web2}", "#{status2}")
insert_sql("#{port3}", "#{web3}", "#{status3}")

puts "Sites checked: "
puts "#{web1}"
puts "#{web2}"
puts "#{web3}"

